/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vm;

import java.io.File;
import javafx.collections.ObservableList;
import javafx.scene.control.TreeItem;

/**
 *
 * @author PauliusD
 */
class FileTreeItem extends TreeItem<File>{
	private boolean notInitialized = true;
	public FileTreeItem(final File file){
		super(file);
               // System.out.println("test");
	}
	@Override
	public ObservableList<TreeItem<File>> getChildren(){
           // System.out.println("test2");
		if(notInitialized){
			notInitialized = false;
			if(getValue().isDirectory()){
				for(final File file:getValue().listFiles()){
					super.getChildren().add(new FileTreeItem(file));
				}
			}
		}
		return super.getChildren();
	}
	@Override
	public boolean isLeaf(){
		return !getValue().isDirectory();
	}
       
       
}